﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace RockScissorPapar
{
    public partial class Form1 : Form
    {
        private int  PlayerWin =0;
        private int computerWin = 0;

        public Form1()
        {
            InitializeComponent();
        }

        private void btnrock_Click(object sender, EventArgs e)  //石头
        {
            
            var fistStr = "石头";
            Play(fistStr);
            
        }

        private void btnscissors_Click(object sender, EventArgs e)//剪刀
        {

            var fistStr = "剪刀";
            Play(fistStr);
        }

        private void btnPaper_Click(object sender, EventArgs e)//布 
        {

            var fistStr = "布";
            Play(fistStr);
        }

        
        //游戏调用
        public void Play(string fistStr)
        {
            //玩家出石头
            lblplayer.Text = fistStr;
            var play = new Player();
            var enumPlayer = play.ShowFist(fistStr);

            //电脑出拳
            var com = new Computer();
            var enumCom = com.ShowFist();
            lblComputer.Text = com.Fist.ToString();

            //裁判出场
            var enumResult = Judge.GetResult((int)enumPlayer, (int)enumCom);
            lblResult.Text = enumResult.ToString();

            if (enumResult == EnumResult.玩家赢)
            {
                PlayerWin++;
                lblPlayerScore.Text = PlayerWin.ToString();
            }
            else if (enumResult == EnumResult.电脑赢)
            {
                computerWin++;
                lblCputerScore.Text = computerWin.ToString();
            }
            else
            { }
        }

        private void btnrestart_Click(object sender, EventArgs e)
        {
            lblPlayerScore.Text = "0";
            lblCputerScore.Text = "0";
            lblResult.Text = "";
        }

          
    }
}
